package com.piesat.quake.business.device.mqtt.reader;

import com.piesat.quake.business.device.mqtt.param.ParseParam;

import io.netty.buffer.ByteBuf;

/**
 * 字符读取器
 *
 * @author Gersy
 * @date 2023/2/6
 * @since 1.0
 */
public class IpReader implements Reader {

    @Override
    public String read(ByteBuf byteBuf, ParseParam param) {
        byte[] bytes = new byte[4];
        byteBuf.readBytes(bytes);
        int number = 0xFF & bytes[0];
        StringBuilder sb=new StringBuilder();
        sb.append(number);
        for (int i = 1; i < bytes.length; i++) {
            sb.append('.').append(0xFF & bytes[i]);
        }
        return sb.toString();
    }
}
